package com.migu.spms.webapi;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.migu.spms.dao.entity.FunctionRequireCriteria;
import com.migu.spms.service.data.User;
import com.migu.spms.service.inf.IUserRoleControlService;
import com.migu.spms.webapi.data.ButtonResponse;
import com.migu.spms.webapi.data.RequirementDetailsResponse;

/**
 * RequirementController类 项目名称: SPMS功能需求 包名称: com.migu.spms.webapi 类名称:
 * RequirementController.java 类描述: 权限控制 创建人: xs 创建时间: 2017年7月10日 上午9:27:52
 */
@SuppressWarnings("all")
@Controller
@RequestMapping(value = "/userRoleControl", produces = "application/json;charset=UTF-8")
public class UserRoleController extends BaseController {

	@Resource(name="IUserRoleControlServiceImpl")
	private IUserRoleControlService userRoleControlService;
	
	/**
	 * 导入导出新建需求3个按钮
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(value = "/buttons")
	public String details(HttpServletRequest req, HttpServletResponse resp, String sessionId) throws Exception {
		int code = 200;
		User user = getUserBySession(req, sessionId);
		if (user == null) {
			return generateResponse(401);
		}
		FunctionRequireCriteria functionRequireCriteria = ParseMsg(req, FunctionRequireCriteria.class);
		Long projectId = functionRequireCriteria.getProjectId();
		ButtonResponse userRoleControl = userRoleControlService.userRoleControl(user, projectId);
		return generateResponse(userRoleControl, 200);
	}
}
